<style type="text/css">
    #danhsach{ 
        width: 900px; height: 500px; padding-top: 10px;
        background: gray; overflow: scroll;
    }
    #danhsach table{border-collapse:collapse; margin: 0 auto;}
    #danhsach td{ border: 1px solid #000; padding: 5px;}
    
</style>

<script type="text/javascript">       
    function chon_hk(value)
    {
        var arr = value.split(".");
                
        $.ajax({
            url: "dangkymh/ajax_list.php",
            type: "POST",
            data: {action: 'chon_hk', nam: arr[1], hocky: arr[0]},
            success: function(result){
                $('#danhsach').html(result);
            }
        })
    }
	    
</script>

<div id="function">
    DANH SÁCH LỚP MỞ
</div>


<div id="function_content" style="float: left;">

    <div id="form" style="float: left; margin-bottom: 10px; margin-left: 30px;">
        <form name="view_info" method="POST" action="?page=quanlysv&function=thongtin">
        <table>
            <tr>
                <td colspan="2"><span style="color: red;"><i>Chọn học kỳ năm:</i></span></td>
            </tr>        
            <tr>
                <td class="label">Chọn: </td>
                <td class="value">
                    <select name="hk-nam" onclick="chon_hk(this.value)">
                    <?php
                        $sql = mysql_query("SELECT HOCKY, NAM FROM lop GROUP BY HOCKY, NAM ORDER BY NAM DESC, HOCKY DESC");
                        if(mysql_num_rows($sql)!=0)
                            while($rows = mysql_fetch_assoc($sql))
                            {
                                echo "<option value='".$rows['HOCKY'].".".$rows['NAM']."'>
                                HK ".$rows['HOCKY']." - NAM ".$rows['NAM']."</option>";
                            }                    
                    ?>
                    </select>
                </td>
                <td></td>
            </tr>
        </table>
        </form> 
    </div>

    <div id="danhsach" style="background: #fff;">
        <table>
            <tr style="background: #247CB9;">
                <td style="text-align: center; color: #fff;">Mã lớp MH</td>
                <td style="text-align: center; color: #fff;">Tên MH</td>
                <td style="text-align: center; color: #fff;">Tên GV</td>
                <td style="text-align: center; color: #fff;">TC Lý thuyết</td>
                <td style="text-align: center; color: #fff;">TC Thực hành</td>
                <td style="text-align: center; color: #fff;">Ca</td>
                <td style="text-align: center; color: #fff;">Thứ</td>
                <td style="text-align: center; color: #fff;">Phòng</td>
                <td style="text-align: center; color: #fff;">Tối đa</td>
                <td style="text-align: center; color: #fff;">Trạng thái</td>
            </tr>
        <?php
            $sql = mysql_query("SELECT * FROM lop, monhoc, giaovien 
            WHERE lop.MAMONHOC = monhoc.MAMONHOC AND lop.MAGIAOVIEN = giaovien.MAGIAOVIEN
            AND lop.HOCKY = (SELECT MAX(HOCKY) FROM lop WHERE NAM = (SELECT MAX(NAM) FROM lop))
            ORDER BY lop.MAMONHOC, MALOP ASC");
            while($rows = mysql_fetch_assoc($sql))
            {
        ?>
        
             <tr>
                 <td style="text-align: center;"><div class="chon_ms">
                        <?php echo $rows['MAMONHOC'].'.'.$rows['MALOP']; ?></div></td>
                 <td><?php echo $rows['TENMONHOC']; ?></td>
                 <td><?php echo $rows['HOTEN']; ?></td>
                 <td style="text-align: center;"><?php echo $rows['TINCHILYTHUYET']; ?></td>                 
                 <td style="text-align: center;"><?php echo $rows['TINCHITHUCHANH']; ?></td>
                 <td style="text-align: center;"><?php echo $rows['CA']; ?></td>
                 <td style="text-align: center;"><?php echo $rows['THU']; ?></td>
                 <td style="text-align: center;"><?php echo $rows['PHONG']; ?></td>
                 <td style="text-align: center;"><?php echo $rows['TOIDA']; ?></td>
                 <td style="text-align: center;"><?php echo $rows['TRANGTHAI']; ?></td>
             </tr>
        
        <?php } ?>
        </table> 
    </div>
</div>
